<body>
<div class="page-container">
	<form action="" method="post" class="form form-horizontal" id="form-user-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>
				分类名称：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input id="cname" type="text" class="input-text" placeholder="" id="user-name" name="product-category-name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">父级类别：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<span class="select-box">
					<select id="select" class="select" size="1" name="demo1">
						<option value="1" selected>全部产品</option>
					</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<div class="col-9 col-offset-2">
				<input id="button" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__ROOT__/static/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__ROOT__/static/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__ROOT__/static/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="__ROOT__/static/admin/lib/layer/2.4/layer.js"></script>
<script type="text/javascript">
$('#button').click(function(event) {
	pid = $('#select').val();
	cname = $('#cname').val();
	$.ajax({
		url: "{:url('admin/product/product_category_add')}",
		type: 'post',
		dataType: 'json',
		data: {pid: pid,cname:cname},
	})
	.done(function( ret ) {
		if( ret.error == '0'){
			layer.alert(ret.msg,{icon:6},function(){
				parent.location.href = ret.url;
			});
		}else{
			layer.alert(ret.msg,{icon:3});
		}
	})
	.fail(function() {
		layer.alert('System error');
	})
});
</script>
</body>
</html>